<?php

class ads extends stwidgets {

    function ads() {
        $this->WP_Widget(false, $name = 'ST Ads');
    }

    function widget($args, $instance) {
        $ads_link_to = $instance['ads_link_to'];
        $ads_url = $instance['ads_url'];
        $ads_width = $instance['ads_width'];
        $ads_title = $instance['ads_title'];
        if($ads_title != ''){
        ?>

            <div class="box">
                <div class="title_left">
                    <div class="title_left_text"><?php echo $ads_title ?></div>
                </div>

                <div class="image_fl">
                    <a href="<?php echo $ads_link_to ?>"><img src="<?php echo $ads_url ?>" style="width: <?php echo $ads_width ?>px; height: auto;"></a>   
                </div>
            </div>

        <?php }else{ ?>
            <div class="image_fl">
                <a href="<?php echo $ads_link_to ?>"><img src="<?php echo $ads_url ?>" style="width: <?php echo $ads_width ?>px; height: auto;"></a>   
            </div>
        <?php
        }
    }

    function form($instance) {
        ?>
        <p>
            <label for="">Title</label>
            <input type="text" name="ads_title" class="widefat" value="<?php echo $instance['ads_title'] ?>">
        </p>
        <p>
            <label for="">Ads image url</label>
            <input type="text" name="ads_url" class="widefat" value="<?php echo $instance['ads_url'] ?>">
        </p>
        <p
            <label for="">Width</label>
            <input type="text" name="ads_width" class="widefat" value="<?php echo $instance['ads_width'] ?>">
        </p>
        <p
            <label for="">Link to</label>
            <input type="text" name="ads_link_to" class="widefat" value="<?php echo $instance['ads_link_to'] ?>">
        </p>
        <?php
    }

}